package com.atguigu.f_ticket;

public class Ticket implements Runnable{
    int count = 50;

    @Override
    public void run() {
        while (true){
                method();
        }
    }

    public synchronized void method(){
        if (count>0){
            System.out.println(Thread.currentThread().getName()+"买到了第"+count+"张票,剩余"+(--count)+"张票");
        }
    }
}
